Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel 2: Simple working JS packager #2239

Merged
merged 1 commit into from
Nov 2, 2018
Merged

Conversation

devongovett
Copy link
Member

Wraps all assets in functions.

nodeFromDep({...dep, sourcePath: file.filePath})
);
let depNodes = assetNode.value.dependencies.map(dep => {
dep.sourcePath = file.filePath;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To discuss: do we even need this field on a dependency? An Asset node points to a Dependency in the graph, so we should be able to infer the file the dep came from based on its location in the graph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used to generate the id when creating the node (

id: `${dep.sourcePath}:${dep.moduleSpecifier}`,
). I like the idea of the value being the only input to create a node, but I suppose we could consider removing it if it really isn't useful and is taking up space.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I saw that. But we could pass the source path as a second argument to nodeFromDep to create the id... Perhaps it is useful information to store on a dep. I'm not sure.

@@ -174,6 +174,7 @@ export default class Parcel {

let file = {filePath: resolvedPath};
if (signal && !signal.aborted) {
dep.resolvedPath = resolvedPath;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about mutating the dep here. Also we might not want to store this in the dep anyway - we could just figure it out based on where it is in the graph. That wouldn't work if we want to cache the resolution though, so perhaps we do want it in the end. Either way, it cannot be on the dep when it is initially created - it will need to be filled in later post-resolution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to add this field to the dep, it might make more sense to do it in the AssetGraph's updateDependency function.

That wouldn't work if we want to cache the resolution though

Are talking about the parcel cache or like the in memory "cache" on the v1 Resolver? Caching in memory is pretty much already taken care of by the way the graph is built. If a file is transformed a second time and finds some of the same dependencies it won't try to resolve them again. As for the parcel cache, I'm wondering if we want to cache resolved paths, at least to begin with. Seems like cache invalidation for that could get hairy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm talking about the filesystem cache here. In Parcel 1 we do cache the resolved paths, and it increases performance very significantly.

let deps = {};

for (let dep of asset.dependencies) {
let resolvedAsset = bundle.assets.find(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a great way to find the resolved ids for deps. It will be slower than necessary for sure. Perhaps another reason to have a bundle contain a Graph instead of a flat list of assets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I can start looking into that. We'll have to be able serialize/deserialize graphs since the packagers will be running in workers. Do you think that could possibly end up making it not worth it performance wise?

Copy link
Contributor

@padmaia padmaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think these comments will naturally be addressed as we flesh out the default bundler more.

nodeFromDep({...dep, sourcePath: file.filePath})
);
let depNodes = assetNode.value.dependencies.map(dep => {
dep.sourcePath = file.filePath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used to generate the id when creating the node (

id: `${dep.sourcePath}:${dep.moduleSpecifier}`,
). I like the idea of the value being the only input to create a node, but I suppose we could consider removing it if it really isn't useful and is taking up space.

let deps = {};

for (let dep of asset.dependencies) {
let resolvedAsset = bundle.assets.find(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I can start looking into that. We'll have to be able serialize/deserialize graphs since the packagers will be running in workers. Do you think that could possibly end up making it not worth it performance wise?

@@ -174,6 +174,7 @@ export default class Parcel {

let file = {filePath: resolvedPath};
if (signal && !signal.aborted) {
dep.resolvedPath = resolvedPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to add this field to the dep, it might make more sense to do it in the AssetGraph's updateDependency function.

That wouldn't work if we want to cache the resolution though

Are talking about the parcel cache or like the in memory "cache" on the v1 Resolver? Caching in memory is pretty much already taken care of by the way the graph is built. If a file is transformed a second time and finds some of the same dependencies it won't try to resolve them again. As for the parcel cache, I'm wondering if we want to cache resolved paths, at least to begin with. Seems like cache invalidation for that could get hairy.

@padmaia padmaia merged commit 50bc06b into v2-work-so-far Nov 2, 2018
@devongovett devongovett deleted the working-packager branch November 2, 2018 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants